#ifndef _USER_SPI_H
#define _USER_SPI_H

#include "driver/gpio.h"


#if CONFIG_IDF_TARGET_ESP32

#define DMA_CHAN                SPI_DMA_CH_AUTO

#define NFC_SPI_MISO_PIN        GPIO_NUM_19
#define NFC_SPI_MOSI_PIN        GPIO_NUM_23
#define NFC_SPI_SCLK_PIN        GPIO_NUM_18
#define NFC_SPI_CS_PIN          GPIO_NUM_5

#define RC522_RST_GPIO_PIN      GPIO_NUM_22         // NFC复位

#elif CONFIG_IDF_TARGET_ESP32S3

#define DMA_CHAN                SPI_DMA_CH_AUTO

#define NFC_SPI_MISO_PIN        GPIO_NUM_18
#define NFC_SPI_MOSI_PIN        GPIO_NUM_17
#define NFC_SPI_SCLK_PIN        GPIO_NUM_16
#define NFC_SPI_CS_PIN          GPIO_NUM_15

#define RC522_RST_GPIO_PIN      GPIO_NUM_8         // NFC复位

#endif


#define SPI_CS_LOW              gpio_set_level(NFC_SPI_CS_PIN, 0)
#define SPI_CS_HIGH             gpio_set_level(NFC_SPI_CS_PIN, 1)

#define RC522_RST_LOW                     0x00
#define RC522_RST_HIGH                    0x01

void user_spi_init(void);
void user_spi_write(uint8_t *pData, uint32_t dataLen);
void user_spi_read(uint8_t *pData, uint32_t dataLen);

#endif
